//
//  ActivityCallupListCell.m
//  wtshoppingcite
//
//  Created by Baojia-LC on 14/11/10.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "ActivityCallupListCell.h"
#import "UIImageView+WebCache.h"
@implementation ActivityCallupListCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = COLOR_RGB(240, 240, 240);
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    
    _actIconView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 50, 50)];
    _actIconView.backgroundColor = [UIColor grayColor];
    [self addSubview:_actIconView];
    
    _addressLabel = [self createLabelWithFrame:CGRectMake(_actIconView.left, _actIconView.bottom+3, SCREEN_WIDTH, 18) text:@"" font:12 textAli:NSTextAlignmentLeft textColor:COLOR_RGB(95, 95, 95)];
    [self addSubview:_addressLabel];

    _typeLabel = [self createLabelWithFrame:CGRectMake(_actIconView.right +10, _actIconView.top, 50, 18) text:@"" font:14 textAli:NSTextAlignmentCenter textColor:[UIColor whiteColor]];
    [self addSubview:_typeLabel];
    
    _titleLabel = [self createLabelWithFrame:CGRectMake(_typeLabel.right, _typeLabel.top, 220, 18) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:COLOR_RGB(95, 95, 95)];
    [self addSubview:_titleLabel];
    
    _timeLabel = [self createLabelWithFrame:CGRectMake(_typeLabel.left, _titleLabel.bottom, 240, 18) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:COLOR_RGB(95, 95, 95)];
    [self addSubview:_timeLabel];
    
    _visitorNumberLabel = [self createLabelWithFrame:CGRectMake(_typeLabel.left, _timeLabel.bottom, 240, 18) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:COLOR_RGB(95, 95, 95)];
    [self addSubview:_visitorNumberLabel];
    
    
}

-(void)setModel:(ActivityCallupModel *)model{
    if(_model != model){
        _model = model;
        
        [_actIconView setImageWithURL:[NSURL URLWithString:_model.image]];
        _addressLabel.text = _model.address;
        if([_model.type isEqualToString:@"最热"]){
            _typeLabel.backgroundColor = COLOR_RGB(245, 88, 141);
        }else{
            _typeLabel.backgroundColor = MAIN_GRAY_COLOR;
        }
        _typeLabel.text = _model.type;
        _titleLabel.text = _model.title;
        _timeLabel.text = _model.time;
        _visitorNumberLabel.text = _model.visitornum;
    }
}

-(UILabel*)createLabelWithFrame:(CGRect)frame text:(NSString*)text font:(int)font textAli:(NSTextAlignment)alig textColor:(UIColor*)tc{
    if(text == nil)
        text = @"";
    UILabel* label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = alig;
    label.textColor = tc;
    label.backgroundColor = [UIColor clearColor];
    return label;
}

@end
